#!/usr/bin/env pytho
# -*- coding: utf-8 -*-
import requests
import json
url = "http://172.16.1.188:8080/api/manage_member/user/auth/login" # 接口地址

username01 = "sichuanshidaiCYDW003"    #* 账号

unitName = "烟台市兴农国际贸易有限公司",   #*成员单位名称
uniformSocialCreditCode = "913706001650403852",            #*成员单位信用代码




payload = {
'password': '123456789',
'username': 'admin',
'uuid': '',
'verifyCode': '',
}
r = requests.post(url, json=payload, verify=False)
# print(r.text)

token = json.loads(r.text)["token"] #获取登录后的token
print(token)

#添加成员单位
urlcy ="http://172.16.1.21/xl-dcs/api/manage/user/normal_admin"

data={
    "isDelete": "false",
    "adminId": "",
    "username": "sichuanshidaiCYDW003",  #* 账号
    "password": "111111",                   #* 密码
    "contractNo": "sichuanshidaiCYDW003",      #*合同编号
    "unitName": "烟台市兴农国际贸易有限公司",  #*成员单位名称
    "uniformSocialCreditCode":"913706001650403852",            #*成员单位信用代码
    "memberType": "3",  #* 成员类型 3到8 140
    "memberProperties": "66",  #*成员身份 [3,9到59+164  4,80到89  5,64到76  6，77到81 7,91到96 8,60到63 140,141]
    "debtClass": ["97"],  # 债务类  97 98 99
    "actionClass": ["100","101"],  # 行为类["100", "101"]
    "region": "北京市,市辖区,海淀区",  #* 所以在地
    "address": "限公司B东3号", #* 详细地址
    "startTime": "2019-01-01T16:00:00.000Z",   #* 签订时间
    "endTime": "2019-09-30T16:00:00.000Z",      #* 到期时间
    "memberPriceId": "17",  #套餐名称ID {17-20}
    "name": "管理员闵明海",     #*管理员姓名
    "mobilePhone": "18612152101",               #*管理员手机
    "email": "132121521011321215210113212152101@qq.com",    #*管理员邮箱
    "telePhone": "",  #管理员座机号
    "department": "管理员所属部门财政部管理", #管理员部门
    "job": "管理员所属部门职务管理员职务",       #管理员职务
    "adminRemark": "管理员所属部门财政部管理管理员所属部门财政部管理", #管理员备注
    "business": "超级管理员管理管理添加部门添加部门,administrator子职位运营部一部全权限,张志超成员的真实姓名", #* 业务人员
    "userRemark": "chengyaundanweizhanghao1成员备注\nchengyaundanweizhanghao1成员备注\nchengyaundanweizhanghao1成员备注\n",
    "operationUser": "",
    "lastLoginTime": "",
    "parentId": "",
    "debtName": "",
    "actionName": "",
    "memberTypeName": "",    "memberPropertiesName": ""
}



data1=json.dumps(data)

headers = {"Accept"	:"application/json, text/plain, */*",
"Accept-Encoding"	:"gzip, deflate",
"Accept-Language"	:"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Authorization"	: token,
"Connection"	:"keep-alive",
"Content-Length"	:"561",
"Content-Type"	:"application/json",
"Host"	:"172.16.1.21",
"Referer"	:"http://172.16.1.21/loginTo/homepage",
"User-Agent"	:"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Safari/537.36"}


r2 = requests.post(url=urlcy, data=data1, headers=headers)

print(r2.status_code)
print(r2.text)


